home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z8.ADF
/
Dazzlers
/
Dazzle.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-12-16
|
4KB
|
151 lines
/************************************************************************
* Dazzlers - Written by Bryan Ford *
* *
* This is a demonstration of the color graphics capabilities of the *
* Amiga - brought to you by a routine I thought of on one of those *
* "hacker's nights" - you know, the kind when you never get to bed. *
* *
* Press the left putton to quit, right button to pause, right button *
* to resume. *
* *
* This program was compiled on Lattice C version 3.03. It *
* will probably work on most other C compilers for the Amiga. *
* *
* This program is in the public domain. Use it as you see fit. *
************************************************************************/
#include "exec/types.h"
#include "graphics/gfx.h"
#include "graphics/rastport.h"
#include "graphics/gfxbase.h"
#include "intuition/intuition.h"
#include "libraries/dos.h"
/* Library bases */
struct IntuitionBase *IntuitionBase; /* = NULL */
struct GfxBase *GfxBase; /* = NULL */
/* Screen stuff */
struct Screen *Scr; /* = NULL */
struct Window *Win; /* = NULL */
/* Secondary bitmap */
struct BitMap *SecBitMap; /* = NULL */
/* Misc */
struct IntuiMessage *IM;
COUNT WideCount = 5;
BOOL NoDazzle; /* = FALSE */
UWORD Code;
/* Finish routine */
VOID Finish(RetCode)
{
/* Free the secondary bitmap */
if (SecBitMap != NULL)
FreeBitMap(SecBitMap);
/* Close the screen and window */
if (Win != NULL)
CloseWindow(Win);
if (Scr != NULL)
CloseScreen(Scr);
/* Close the libraries */
if (IntuitionBase != NULL)
CloseLibrary(IntuitionBase);
if (GfxBase != NULL)
CloseLibrary(GfxBase);
/* Exit */
exit(RetCode);
}
/* Open the libraries */
VOID OpenLibs()
{
/* Open the Graphics library */
if ((GfxBase = (struct GfxBase*)
OpenLibrary("graphics.library",32)) == NULL)
Finish(RETURN_FAIL);
/* Open the Intuition library */
if ((IntuitionBase = (struct IntuitionBase*)
OpenLibrary("intuition.library",32)) == NULL)
Finish(RETURN_FAIL);
}
struct NewScreen NewScr = {
0, 0, 320, 200, 5, 0, 0, NULL, CUSTOMSCREEN};
struct NewWindow NewWin = {
0, 0, 320, 200, 0, 0, MOUSEBUTTONS, SIMPLE_REFRESH | BACKDROP |
BORDERLESS | ACTIVATE | RMBTRAP | NOCAREREFRESH, NULL, NULL, NULL,
NULL, NULL, 0, 0, 0, 0, CUSTOMSCREEN};
VOID OpenScr()
{
/* Open the screen */
if ((Scr = (struct Screen*)OpenScreen(&NewScr)) == NULL)
Finish(RETURN_ERROR);
/* Open the window */
NewWin.Screen = Scr;
if ((Win = (struct Window*)OpenWindow(&NewWin)) == NULL)
Finish(RETURN_ERROR);
/* Get the title bar out of here */
ShowTitle(Scr,FALSE);
/* Black background */
SetRGB4(&Scr->ViewPort,0,0,0,0);
}
VOID OpenBM()
{
/* Create the secondary Bitmap */
if ((SecBitMap = (struct BitMap*)
AllocBitMap(322,202,5,TRUE)) == NULL)
Finish(RETURN_ERROR);
}
VOID main()
{
/* Setup */
OpenLibs();
OpenScr();
OpenBM();
FOREVER {
if (NoDazzle == FALSE) {
/* Plant some junk */
SetAPen(Win->RPort,RangeRand(32));
WritePixel(Win->RPort,RangeRand(320),RangeRand(200));
/* Abracadabra - figure this out yourself! */
BltRastPortBitMap(Win->RPort,0,0,SecBitMap,1,0,320,200,0x0c0);
BltRastPortBitMap(Win->RPort,0,0,SecBitMap,1,2,320,200,0x0e0);
BltRastPortBitMap(Win->RPort,0,0,SecBitMap,0,1,320,200,0x0e0);
BltRastPortBitMap(Win->RPort,0,0,SecBitMap,2,1,320,200,0x0e0);
BltRastPortBitMap(Win->RPort,0,0,SecBitMap,1,1,320,200,
--WideCount ? 0x0e0 : 0x020);
BltBitMapRastPort(SecBitMap,1,1,Win->RPort,0,0,320,200,0x0c0);
if (WideCount == 0)
WideCount = RangeRand(7) + 1;
}
/* Check for IntuiMessages */
if ((IM = (struct IntuiMessage*)GetMsg(Win->UserPort)) != NULL) {
Code = IM->Code;
ReplyMsg(IM);
if (Code == SELECTDOWN)
Finish(RETURN_OK);
if (Code == MENUDOWN)
NoDazzle ^= 1;
}
}
}